package com.kunchi.isb.base.exception;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.omg.CORBA.UNKNOWN;

/**
 * ISB规范化的异常对象，当出问题时，会包含在Result一同返回给调用方。
 *
 * @author keel2008
 */
@ApiModel(value = "ISB异常", description = "包含异常编码，类型，信息，错误堆栈")
public class ISBException extends Exception {

    public static String UNKNOWN_ERROR_CODE = "0";

    public ISBException(String code, String message) {
        super(message);
        this.errorCode = code;
        this.message = message;
    }

    public ISBException(String code, String message, Throwable t) {
        super(message, t);
        this.errorCode = code;
        this.message = message;
        if (t != null) {
            this.errorStacks = ExceptionUtils.getStackTrace(t);
        }
    }

    /**
     * 异常编码
     */
    @ApiModelProperty(value = "异常编码", name = "异常编码", example = "0")
    private String errorCode;

    /**
     * 未知错误
     */
    @ApiModelProperty(value = "简述", name = "简述", example = "订单下单的处理失败")
    private String message = null;

    /**
     * 异常编码
     */
    @ApiModelProperty(value = "异常堆栈", name = "异常堆栈", example = "")
    private String errorStacks = null;
}
